package com.itheima.tanhua.service;

import cn.hutool.core.convert.Convert;
import com.itheima.tanhua.api.mongo.UserLocationApi;
import com.itheima.tanhua.web.BaiduController;
import com.itheima.tanhuan.vo.mongo.UserLocationVo;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;

@Service
public class BaiduService {

    @DubboReference
    UserLocationApi userLocationApi;
    @Autowired
    StringRedisTemplate stringRedisTemplate;

    /**
     * 位置更新
     *
     * @param longitude 经度
     * @param latitude  维度
     * @param address   地址描述
     */
    public void updateLocation(Double longitude, Double latitude, String address) {
        Long uid = Convert.toLong(stringRedisTemplate.opsForValue().get("UID"));
        //更新用户地址
        Boolean updateLocation = userLocationApi.updateLocationByUid(uid,longitude,latitude,address);

    }
}
